{% extends "base.html" %}
{% block content %}
<title>{{ title }} - {{ user.username }}的主页</title>
<div class="container mt-4">
    <h2>{{ user.username }}的主页</h2>
    <div class="avatar-section mb-4">
        <img src="{{ url_for('static', filename='uploads/avatars/' + user.avatar_filename) if user.avatar_filename else url_for('static', filename='images/default_avatar.png') }}" 
             alt="头像" class="profile-avatar rounded-circle" style="width: 150px; height: 150px;">
        {% if session.user_id == user.id %}
        <form method="post" enctype="multipart/form-data" action="{{ url_for('upload_avatar') }}" class="mt-3">
            <input type="file" name="avatar" accept="image/*" class="form-control mb-2">
            <button type="submit" class="btn btn-primary">更换头像</button>
        </form>
        {% endif %}
    </div>
    
    <h3>上传的视频</h3>
    <div class="row">
        {% for video in videos %}
        <div class="col-md-4 mb-4">
            <div class="card">
                <a target="_blank" href="{{ url_for('play', video_filename=video.video_filename) }}">
                    <img src="{{ url_for('static', filename='uploads/covers/' + video.cover_filename) }}" 
                         class="card-img-top" 
                         alt="{{ video.title }}">
                </a>
                <div class="card-body">
                    <h5 class="card-title">{{ video.title }}</h5>
                    <p class="card-text">{{ video.description }}</p>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}